import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // layout
  {
    path: '/',
    component: () => import('@/views/layout'),
    children: [
      { path: '/', name: 'home', component: () => import('@/views/home') },
      { path: '/company', name: 'company', component: () => import('@/views/company') },
      { path: '/staff', name: 'staff', component: () => import('@/views/staff') },
      { path: '/my', name: 'my', component: () => import('@/views/my') }
    ]
  },
  { path: '/login', name: 'login', component: () => import('@/views/login') },
  // 首页
  { path: '/commerce', name: 'commerce', component: () => import('@/views/home/commerce') },
  { path: '/job-wanted', name: 'job', component: () => import('@/views/home/job-wanted') },
  { path: '/service', name: 'service', component: () => import('@/views/home/service') },
  { path: '/standard', name: 'standard', component: () => import('@/views/home/standard') },
  // 家政公司
  { path: '/company/detail/:id', name: 'company', component: () => import('@/views/company/company-detail'), props: true },
  // 家服人员
  { path: '/staff/detail/:id', name: 'staff', component: () => import('@/views/staff/staff-detail'), props: true },
  // 用户
  { path: '/user/personal', name: 'personal', component: () => import('@/views/user') },
  { path: '/user/follow', name: 'follow', component: () => import('@/views/user/follow') },
  { path: '/user/comment', name: 'comment', component: () => import('@/views/user/comment') },
  { path: '/user/contact', name: 'contact', component: () => import('@/views/user/contact') },
  // 我的
  { path: '/my/about', name: 'about', component: () => import('@/views/my/about') },
  { path: '/my/authorize/staff', name: 'staff', component: () => import('@/views/my/authorize-staff') },
  { path: '/my/authorize/admin', name: 'admin', component: () => import('@/views/my/authorize-admin') }
]

const router = new VueRouter({
  mode: 'history', // require service support
  base: '/housekeeping/', // 配置项目的基础地址
  scrollBehavior: () => ({ y: 0 }), // 管理滚动行为 如果出现滚动 切换就让 让页面回到顶部
  routes
})

export default router
